include "domain.thrift"

namespace java com.salmon.thrift
namespace py com.salmon.thrift
namespace cpp com.salmon.thrift
namespace csharp com.salmon.thrift

typedef domain.BucketInfo BucketInfo
typedef domain.ObjectListResult ObjectListResult
typedef domain.OssObjectSummary OssObjectSummary
typedef domain.OssObject OssObject

exception InvalidOperation {
    1: i32 code,
    2: string why
}

service OssHandlerService {
    bool createBucket(1:string bucketName,2:string detail, 3: string token) throws (1:InvalidOperation ouch),
    bool deleteBucket(1:string bucket, 2: string token) throws (1:InvalidOperation ouch),
    BucketInfo getBucketInfo(1: string bucket, 2: string token) throws (1:InvalidOperation ouch),
    list<BucketInfo> listBucket(1: string token) throws (1:InvalidOperation ouch),


    ObjectListResult listObject(1: string bucket,2: string startKey,3: string endKey, 4: string token) throws (1:InvalidOperation ouch),
    /**
     * 根据前缀过滤
     */
    ObjectListResult listObjectByPrefix(1:string bucket,2:string dir,3:string prefix,4:string start,5:string token) throws (1:InvalidOperation ouch),
    /**
     * 列出bucket对应目录下的所有文件，当start key 不为空时，从start key进行查询
     */
    ObjectListResult listObjectByDir(1:string bucket,2:string dir,3:string startKey,4:string token) throws (1:InvalidOperation ouch),
    OssObjectSummary getObjectSummary(1:string bucket, 2: string key, 3: string token) throws (1:InvalidOperation ouch),
    OssObject getObject(1:string bucket, 2: string key, 3: string token) throws (1:InvalidOperation ouch),
    bool deleteObject(1: string bucket,2: string key, 4: string token) throws (1:InvalidOperation ouch),
    bool putObject(1: string bucket, 2: string key, 3: binary buffer, 4: string mediaType, 5: map<string, string> attrs, 6: string token) throws (1:InvalidOperation ouch)
}